package com.gxa.system_setting.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gxa.common.R;
import com.gxa.common.entity.system_settings.SensitiveWords;
import com.gxa.system_setting.mapper.SensitiveWordsMapper;
import com.gxa.system_setting.service.SensitiveWordsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class SensitiveWordsServiceImpl implements SensitiveWordsService {

    @Autowired
    private SensitiveWordsMapper sensitiveWordsMapper;

    @Override
    public R SensitiveWordsList(Integer currentPage, Integer pageSize) {
        R r=new R();
        Page<SensitiveWords> page=new Page(currentPage,pageSize);
        Page<SensitiveWords> sensitiveWordsPage = sensitiveWordsMapper.selectPage(page, null);
        r.setCode(200);
        r.setMessage("分页查询成功");
        r.setData(sensitiveWordsPage);
        return r;
    }

    @Override
    public R insertSensitiveWords(SensitiveWords sensitiveWords) {
        R r=new R();
        int i = sensitiveWordsMapper.insert(sensitiveWords);
        r.setCode(200);
        r.setMessage("添加成功");
        r.setData(i);
        return r;
    }

    @Override
    public R selectByConditions(Map map) {
        R r=new R();
        List<SensitiveWords> sensitiveWordsList=sensitiveWordsMapper.selectByConditions(map);
        r.setCode(200);
        r.setMessage("查询成功");
        r.setData(sensitiveWordsList);
        return r;
    }

    @Override
    public R batchUpdateStatus(Long[] sensitive_word_ids, Integer status) {
        R r=new R();
        int i=sensitiveWordsMapper.batchUpdateStatus(sensitive_word_ids,status);
        r.setCode(200);
        r.setMessage("批量修改成功");
        r.setData(i);
        return r;
    }

    @Override
    public R batchDelSensitiveWordsList(Long[] sensitive_word_ids) {
        R r=new R();
        int i=sensitiveWordsMapper.batchDelSensitiveWordsList(sensitive_word_ids);
        r.setCode(200);
        r.setMessage("批量删除成功");
        r.setData(i);
        return r;
    }

    @Override
    public R updateSensitiveWords(SensitiveWords sensitiveWords) {
        R r=new R();
        int i=sensitiveWordsMapper.updateSensitiveWordsById(sensitiveWords);
        r.setCode(200);
        r.setMessage("修改成功");
        return r;
    }
}
